package com.ruoyi.web.controller.control;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.control.domain.MonorailcraneHistory;
import com.ruoyi.control.service.IMonorailcraneHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 单轨吊历史Controller
 *
 * @author ruoyi
 * @date 2024-12-20
 */
@RestController
@RequestMapping("/monorailcraneHistory/monorailcraneHistory")
public class MonorailcraneHistoryController extends BaseController
{
    @Autowired
    private IMonorailcraneHistoryService monorailcraneHistoryService;

    /**
     * 查询单轨吊历史列表
     */
    @PreAuthorize("@ss.hasPermi('monorailcraneHistory:monorailcraneHistory:list')")
    @GetMapping("/list")
    public TableDataInfo list(MonorailcraneHistory monorailcraneHistory)
    {
        startPage();
        List<MonorailcraneHistory> list = monorailcraneHistoryService.selectMonorailcraneHistoryList(monorailcraneHistory);
        return getDataTable(list);
    }

    /**
     * 导出单轨吊历史列表
     */
    @PreAuthorize("@ss.hasPermi('monorailcraneHistory:monorailcraneHistory:export')")
    @Log(title = "单轨吊历史", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MonorailcraneHistory monorailcraneHistory)
    {
        List<MonorailcraneHistory> list = monorailcraneHistoryService.selectMonorailcraneHistoryList(monorailcraneHistory);
        ExcelUtil<MonorailcraneHistory> util = new ExcelUtil<MonorailcraneHistory>(MonorailcraneHistory.class);
        util.exportExcel(response, list, "单轨吊历史数据");
    }

    /**
     * 获取单轨吊历史详细信息
     */
    @PreAuthorize("@ss.hasPermi('monorailcraneHistory:monorailcraneHistory:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(monorailcraneHistoryService.selectMonorailcraneHistoryById(id));
    }

    /**
     * 新增单轨吊历史
     */
    @PreAuthorize("@ss.hasPermi('monorailcraneHistory:monorailcraneHistory:add')")
    @Log(title = "单轨吊历史", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MonorailcraneHistory monorailcraneHistory)
    {
        return toAjax(monorailcraneHistoryService.insertMonorailcraneHistory(monorailcraneHistory));
    }

    /**
     * 修改单轨吊历史
     */
    @PreAuthorize("@ss.hasPermi('monorailcraneHistory:monorailcraneHistory:edit')")
    @Log(title = "单轨吊历史", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MonorailcraneHistory monorailcraneHistory)
    {
        return toAjax(monorailcraneHistoryService.updateMonorailcraneHistory(monorailcraneHistory));
    }

    /**
     * 删除单轨吊历史
     */
    @PreAuthorize("@ss.hasPermi('monorailcraneHistory:monorailcraneHistory:remove')")
    @Log(title = "单轨吊历史", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(monorailcraneHistoryService.deleteMonorailcraneHistoryByIds(ids));
    }
}
